$('.main-nav').on('click', 'li', function(){
	$(this).siblings().removeClass('current').end().addClass('current');
	$('#iframe').attr('src', $(this).attr('data-src'));
});


$(window).resize(function(e) {
    $("#bd").height($(window).height() - $("#hd").height() - $("#ft").height()-6);
	$(".wrap").height($("#bd").height()-6);
	$("#iframe").height($(window).height() - $("#hd").height() - $("#ft").height() - 6);
}).resize();


$('.exitDialog').Dialog({
	title:'确认退出系统吗?',
	autoOpen: false,
	width:400,
	height:200
	
});

$('.exit').click(function () {

	$('.exitDialog').Dialog('open');
});


$('.exitDialog input[type=button]').click(function(e) {
    $('.exitDialog').Dialog('close');
	
	if($(this).hasClass('ok')){
	    window.location.href = "/magerlogin/LogOut";
	}
});

$('.pwdchange').click(function () {

	$('.PwdChangeDialog').Dialog('open');
});

$('.PwdChangeDialog').Dialog({
	title: '修改密码',
	autoOpen: false,
	width: 400,
	height: 200

});

$('.PwdChangeDialog input[type=button]').click(function (e) {


	if ($(this).hasClass('ok')) {
		saveInfo();
	}
	else {
		$('.PwdChangeDialog').Dialog('close');
	}
});



function saveInfo() {
    var oldpwd = $("#oldpwd").val();
    if (oldpwd == '') {
        alert("请填写旧密码");
        return;
    }
    var newpwd = $("#newpwd").val();
    if (newpwd == '' || newpwd.length < 6) {
        alert("请填写不小于6位的新密码");
        return;
    }

    var newpwd2 = $("#newpwd2").val();
    if (newpwd2 == '') {
        alert("请填写确认密码");
        return;
    }


    if (newpwd != newpwd2) {
        alert("两次密码输入不一致");
        return;
    }

    var data = $("#addForm").serializeArray(); //自动将form表单封装成json

    $.post("SavePwd?actionorder=upd", data, retrunResult, "json");



}
function retrunResult(respBean) {
    var code = respBean.respCode;
    var msg = respBean.respMsg;
    //alert(msg);
    if (code == 200) {
        //
        alert("密码修改成功");
        document.getElementById("oldpwd").value = "";//清除隐藏域内容
        document.getElementById("newpwd").value = "";
        document.getElementById("newpwd2").value = ""
        $('.PwdChangeDialog').Dialog('close');
    }
    else if (code == '200000') {
        alert(msg);
    }
    else {
        $(".ui-button ui-corner-all ui-widget").attr('disabled', false);
        alert(msg);
    }
}